<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=], initial-scale=1.0">
    <title>练习1:用户登录状态显示</title>
    <script src="../../js/vue.js"></script>
</head>
<body>
    <div id="app">
        <h2>{{msg}}</h2>
        
        <div id="statusDisplay" class="status-display logged-out">
            当前状态：{{loginText}}
        </div>
        
        <div v-show="show">
            <div>
                <div>U</div>
            </div>
            <p>欢迎回来！</p>
            <p><strong>用户名：</strong> <span>user123</span></p>
            <p><strong>邮箱：</strong> <span>user@example.com</span></p>
            <p><strong>登录时间：</strong> <span>2023-07-20 10:30:00</span></p>
        </div>
        
        <button @click="login">
            {{buttonText}}
        </button>
    </div>

</body>
</html>

<script>
    var app = new Vue({
        el: '#app',
        data: {
            msg: '用户登录状态',
            show: false,
            loginText: '未登录',
            buttonText: '登录',
        },
        methods: {
            login(){
                this.show = !this.show;
                this.loginText = this.show ? '已登录' : '未登录';
                this.buttonText = this.show ? '注销' : '登录';
            }
        }
    })
</script>